<div style="width:100%; height:200px; overflow-x:auto; overflow-y:hidden; border:solid 1px #808080;">
<canvas id="canvas" width="11000" height="200" style="border:solid 1px #000000;"></canvas>
</div>
See console output for decoded message

<script>
//var d = [540, 7980, 540, 4080, 540, 4060, 500, 4100, 500, 4140, 560, 1760, 540, 4060, 540, 1860, 520, 4140, 560, 3940, 540, 4060, 520, 1880, 540, 1940, 540, 1780, 540, 4040, 540, 1880, 540, 1940, 520, 1800, 540, 4020, 540, 1880, 520, 4160, 520, 1760, 560, 1860, 520, 1880, 520, 4160, 540, 3960, 540, 1860, 540, 4040, 520, 4160, 540, 1800, 500, 4060, 540, 4080, 500, 1980, 520, 1780, 540, 4040, 520, 4080, 520, 1940, 560, 1780, 520, 1880, 520, 1860, 540, 4060, 580];
//var d = [900, 1040, 880, 1060, 880, 980, 860, 1080, 880, 1060, 800, 1080, 840, 1060, 880, 540, 380, 1060, 340, 580, 880, 520, 380, 1080, 360, 560, 880, 580, 340, 1020, 440, 500, 860, 1100, 880, 1020, 840, 580, 380, 1000, 880, 1100, 340, 520, 860, 1120, 820, 520, 420, 1020, 860, 1040, 380, 580, 840, 560, 400, 1040, 880, 1040, 840, 1080, 800, 1100, 840, 1060, 340, 580, 880, 560, 340, 1100, 820, 1040, 880, 1060, 380, 540, 860, 540, 360, 1100, 840, 1040, 860, 1060, 340, 580, 880, 540, 420, 1020, 860, 1020, 880, 1060, 860, 1020, 420, 540, 880, 540, 340, 1060, 880, 1040, 380, 540, 900, 1000, 840, 1080, 880, 540, 400, 1040, 420, 500, 880, 1020, 900, 540, 380, 1040, 880, 1040, 840, 1080, 840, 1040, 880, 1040, 840, 1080, 860, 1040, 800, 1100, 840, 1080, 820, 1100, 380, 560, 840, 540, 340, 1100, 400, 520, 840, 1060, 920, 500, 440, 1000, 380, 540, 900, 540, 340, 1120, 840, 1020, 380, 560, 820, 600, 340, 1100, 860, 1060, 840, 1040, 380, 580, 800, 1080, 880, 560, 340, 1060, 380, 580, 880];
var d = [560, 4060, 540, 4040, 540, 4060, 520, 4160, 520, 1780, 540, 4060, 520, 1880, 520, 4140, 540, 3980, 520, 4040, 540, 1900, 520, 1960, 520, 1780, 520, 4060, 520, 1900, 500, 1980, 500, 1800, 540, 4040, 560, 1860, 540, 4120, 540, 1780, 520, 1860, 560, 1840, 560, 4140, 540, 3940, 560, 1840, 560, 4040, 540, 4140, 560, 1760, 520, 4080, 520, 4060, 520, 1960, 540, 1760, 560, 4040, 540, 4060, 540, 1940, 520, 1780, 560, 1840, 540, 1860, 520, 4100, 580];
//var d = [1360, 1000, 1340, 1040, 1340, 1000, 1360, 1020, 560, 1000, 1360, 1020, 560, 1020, 1340, 940, 1360, 1000, 1320, 1060, 1320, 1000, 1360, 940, 580, 1040, 1320, 1020, 580, 1020, 540, 960, 560, 1020, 580, 1020, 540, 1020, 1380, 940, 1320, 980, 620, 1020, 1340, 1000, 560, 960, 1340, 1040, 1340, 1000, 580, 1000, 560, 960, 1360, 1000, 1340, 1040, 520, 1040, 560, 960, 1340, 1000, 580, 1020, 1340, 1020, 560, 960, 1340, 1000, 1360, 1000, 560, 1020, 600, 940, 1340, 1020, 580, 1000, 540, 1020, 1360];
//var d = [20, 80, 140, 960, 940, 460, 460, 480, 500, 880, 500, 480, 480, 440, 500, 460, 960, 940, 460, 480, 460, 460, 960, 460, 480, 940, 460, 480, 980, 920, 980, 360, 540, 460, 480, 960, 960, 940, 480, 460, 960, 960, 940, 980, 500, 100, 60, 40, 80, 40, 980, 960, 460, 480, 980, 420, 460, 960, 520, 80, 80, 180, 1000, 460, 480, 440, 480, 460, 480, 920, 500, 420, 580, 380, 460, 500, 480, 420, 480, 480, 460, 460, 980, 920, 500, 460, 460, 480, 440, 460, 480, 460, 980, 460, 440, 980, 940, 440, 500, 940, 960, 960, 520, 420, 480, 460, 980, 920, 940, 920, 520, 440, 500, 460, 940, 480, 540, 380, 480, 940, 460, 500, 460, 440, 500, 120, 80, 200, 460, 480, 480, 460, 480, 460, 440, 480, 940, 480, 480, 940, 940, 980, 460, 460, 100];
//var d = [60, 500, 340, 620, 320, 600, 380, 520, 400, 540, 400, 560, 340, 600, 340, 600, 340, 540, 400, 560, 400, 500, 420, 540, 420, 500, 420, 520, 400, 520, 420, 540, 400, 500, 440, 500, 460, 480, 420, 500, 460, 480, 440, 500, 440, 460, 460, 980, 940, 980, 940, 960, 940, 960, 460, 480, 940, 980, 440, 480, 940, 460, 500, 940, 460, 460, 460, 460, 500, 460, 480, 440, 980, 960, 460, 440, 480, 460, 460, 480, 480, 460, 440, 480, 960, 960, 960, 940, 460, 480, 460, 480, 460, 460, 460, 480, 460, 480, 460, 500, 440, 460, 460, 480, 480, 440, 460, 500, 460, 460, 480, 460, 460, 460, 460, 460, 480, 480, 460, 460, 480, 460, 460, 460, 500, 460, 440, 480, 460, 480, 460, 480, 460, 460, 960, 940, 500, 440, 480, 460, 480, 440, 980, 960, 460, 440, 1000, 920, 460, 460, 1000, 920, 480, 460, 960, 940, 960, 980, 460, 440, 480, 460, 980, 940, 460, 440, 500, 480, 460, 460, 460, 480, 960, 440, 480, 940, 960, 960, 460, 460, 980, 420, 500, 960, 960, 960, 940, 960, 460, 480, 480]
//var d = [100, 660, 260, 660, 320, 660, 240, 660, 280, 680, 260, 660, 280, 640, 280, 680, 260, 680, 240, 660, 300, 680, 240, 640, 300, 660, 240, 660, 280, 680, 280, 700, 260, 620, 280, 640, 280, 680, 260, 660, 280, 660, 280, 660, 240, 680, 280, 1160, 740, 1160, 760, 660, 280, 1160, 240, 740, 220, 620, 800, 1120, 320, 620, 760, 1200, 240, 700, 240, 640, 780, 1140, 300, 620, 780, 1180, 240, 660, 280, 660, 260, 680, 260, 640, 760, 700, 260, 1160, 260, 660, 260, 680, 280, 640, 780, 640, 280, 1180, 240, 680, 740, 1160, 240, 700, 760, 1140, 760, 1120, 300, 640, 280, 680, 260, 680, 260, 660, 280, 640, 780, 640, 300, 1180, 720, 1140, 280, 680, 740, 1160, 280, 680, 240, 680, 240, 640, 320, 620, 280, 720, 240, 640, 780, 660, 280, 1120, 300, 640, 760, 1180, 240, 680, 280, 640, 260, 660, 280, 680, 260, 660, 280, 660, 260, 700, 740, 620, 300, 1160, 240, 680, 260, 700, 740, 1140, 280, 680, 280, 640, 280, 700, 720, 680, 260, 640, 280, 680, 280, 680, 240];
var d = [520, 500, 420, 520, 400, 520, 440, 520, 400, 520, 400, 540, 400, 520, 440, 500, 440, 480, 440, 500, 440, 500, 460, 440, 460, 500, 420, 500, 440, 520, 420, 520, 420, 500, 460, 460, 480, 440, 480, 440, 500, 460, 480, 460, 460, 460, 480, 920, 980, 940, 960, 460, 500, 440, 500, 440, 480, 460, 480, 920, 500, 460, 500, 420, 980, 920, 980, 940, 480, 440, 500, 460, 460, 460, 960, 940, 980, 920, 500, 460, 480, 440, 480, 440, 960, 460, 520, 920, 960, 480, 480, 420, 500, 460, 480, 440, 500, 920, 480, 440, 500, 440, 500, 420, 500, 440, 500, 440, 980, 960, 440, 460, 480, 460, 500, 420, 520, 440, 480, 460, 480, 420, 500, 460, 480, 440, 500, 440, 500, 440, 480, 440, 480, 460, 980, 440, 480, 960, 960, 440, 500, 460, 460, 960, 460, 460, 500, 420, 980, 440, 500, 440, 500, 920, 960, 960, 960, 940, 980, 920, 960, 460, 500, 940, 960, 960, 460, 460, 960, 460, 480];
//keeloq
var d = [520, 500, 480, 520, 480, 520, 500, 500, 480, 520, 480, 540, 480, 520, 480, 520, 480, 520, 480, 540, 480, 520, 480, 520, 460, 520, 500, 520, 480, 500, 520, 480, 500, 480, 520, 500, 500, 500, 500, 480, 520, 500, 520, 500, 520, 440, 540, 480, 500, 480, 520, 520, 500, 480, 520, 480, 520, 480, 520, 480, 520, 500, 500, 500, 500, 500, 500, 480, 520, 500, 500, 480, 520, 480, 560, 440, 540, 480, 520, 460, 540, 480, 500, 480, 560, 460, 500, 500, 520, 480, 500, 480, 560, 500, 480, 480, 540, 480, 520, 460, 520, 480, 540, 460, 560, 440, 540, 480, 520, 480, 500, 480, 540, 480, 520, 500, 500, 480, 520, 480, 520, 480, 540, 460, 520, 500, 520, 480, 520, 440, 560, 460, 520, 480, 540, 480, 500, 500, 520, 500, 500, 480, 520, 480, 500, 480, 560, 460, 520, 480, 540, 480, 500, 480, 520, 480, 540, 480, 520, 480, 520, 460, 520, 480, 520, 480, 540, 480, 500, 480, 520, 500, 500, 480, 540, 480, 500, 520, 480, 520, 500, 480, 500, 480, 540, 480, 540, 460, 520, 480, 540, 480, 520, 460, 520, 460, 560, 480, 500, 480, 540, 480, 520, 480, 520, 500, 500, 480, 520, 460, 520, 500, 520, 480, 520, 500, 500, 480, 520, 480, 520, 480, 500, 520, 520, 460, 520, 500, 520, 480, 520, 480, 500, 480, 540, 480, 520, 460, 540, 480, 520, 500, 480, 480, 560, 480, 500, 480, 520, 500, 500, 460, 1060, 480, 800, 720, 800, 740, 780, 760, 500, 480, 500, 1040, 500, 480, 520, 480, 540, 460, 520, 500, 520, 460, 540, 480, 500, 480, 520, 500, 1020, 480, 560, 960, 520, 480, 1060, 1000, 500, 480, 1060, 500, 500, 1000, 520, 480, 520, 500, 520, 480, 520, 480, 500, 480, 540, 480, 520, 460, 520, 480, 520, 480, 520, 480, 1060, 460, 520, 520, 480, 1040, 480, 500, 520, 500, 1020, 1020, 520, 480, 520, 480, 500, 500, 1040, 1000, 500, 500, 1020, 1020, 520, 460, 1080, 980, 1040, 1000, 1020, 1020, 1040, 1000, 520, 480, 540, 480, 1020, 1040, 500, 480, 1040, 500, 480, 480, 520, 1020, 540, 460, 1060, 980, 1040, 480, 500, 520, 480, 500, 540, 980, 520, 480, 1040, 1000, 1040, 1040, 1020, 480, 500];

// ba
var d = [880, 1120, 900, 1080, 920, 580, 400, 560, 400, 1120, 380, 560, 400, 600, 380, 600, 920, 1080, 380, 600, 400, 560, 900, 600, 400, 1080, 380, 600, 880, 1100, 920, 600, 340, 600, 400, 1080, 900, 1120, 400, 580, 880, 1120, 900, 1080, 400, 600, 900, 1080, 380, 600, 400, 560, 400, 600, 380, 560, 440, 560, 900, 600, 400, 560, 400, 580, 400, 1080, 900, 600, 400, 560, 420, 560, 400, 600, 400, 560, 380, 1120, 900, 1080, 920, 600, 340, 600, 400, 600, 380, 1080, 920, 600, 380, 560, 400, 1120, 900, 1080, 400, 560, 900, 1120, 900, 1080, 900, 1080, 920, 1100, 880, 600, 400, 580, 400, 560, 440, 1060, 400, 600, 380, 580, 900, 1080, 900, 1120, 400, 560, 380, 600, 920, 1080, 380];
var d = [1320, 1180, 1280, 1180, 1300, 1140, 500, 1180, 1280, 1180, 460, 1180, 1340, 1080, 1280, 1180, 1280, 1180, 1300, 1140, 1320, 1080, 500, 1180, 1280, 1180, 500, 1160, 480, 1080, 500, 1140, 500, 1180, 500, 1140, 1320, 1080, 1300, 1180, 500, 1140, 500, 1140, 1320, 1080, 1320, 1160, 1320, 1140, 500, 1140, 1320, 1080, 1320, 1160, 1320, 1140, 1320, 1140, 500, 1080, 1320, 1160, 480, 1180, 500, 1160, 1280, 1120, 1320, 1140, 1280, 1180, 500, 1160, 1280, 1120, 1280, 1180, 500, 1140, 1320, 1160, 1280];
var d = [460, 4240, 580, 4200, 580, 4300, 540, 1900, 540, 4240, 580, 1940, 540, 4340, 540, 1860, 560, 4260, 560, 4200, 580, 2040, 520, 1900, 540, 4240, 580, 1920, 600, 1980, 560, 1860, 580, 4220, 580, 1920, 560, 4340, 540, 4180, 580, 1880, 600, 4220, 580, 2000, 540, 4300, 540, 1820, 600, 1940, 540, 4320, 560, 1860, 580, 1940, 540, 4260, 560, 2020, 560, 4140, 580, 1940, 560, 1920, 580, 4300, 540, 1900, 540, 1960, 580, 1940, 560, 4220, 580];
var d = [1400, 1060, 1420, 1060, 600, 1080, 1380, 1040, 600, 1080, 1380, 1020, 1380, 1040, 1440, 1080, 1380, 1040, 1380, 1020, 600, 1080, 1380, 1040, 600, 1080, 560, 1020, 560, 1080, 600, 1080, 560, 1080, 560, 1020, 1380, 1080, 600, 1040, 600, 1080, 1380, 1020, 1380, 1040, 1420, 1060, 1420, 1040, 600, 980, 1420, 1080, 560, 1040, 600, 1080, 1380, 1020, 1380, 1080, 600, 1040, 600, 1080, 1380, 1020, 1380, 1060, 1420, 1040, 1380, 1080, 600, 980, 600, 1080, 1380, 1080, 1380, 1080, 1400];

var d = [420, 2000, 500, 4160, 500, 2000, 500, 4200, 460, 4200, 460, 2040, 460, 2060, 460, 4200, 460, 2020, 500, 2000, 500, 4200, 460, 4200, 460, 2040, 460, 4220, 460, 2020, 500, 2000, 500, 4160, 500, 2000, 500, 2040, 460, 2040, 460, 2040, 460, 2040, 460, 4220, 460, 4200, 460, 4200, 460, 4200, 460, 4220, 460, 4200, 500, 4160, 500, 4160, 500, 2020, 480, 4200, 480, 4160, 500, 4300, 500, 4360, 440];
console.log(d.length);
/*
var d = [460, 4240, 460, 4220, 460, 2060, 460, 2060, 480, 2000, 480, 2060, 460, 2060, 460, 4220, 460, 4240, 460, 2040, 460, 2060, 500, 4180, 500, 2060, 460, 2040, 480, 2040, 460, 2060, 460, 2060, 460, 2040, 460, 2060, 460, 4220, 480, 4220, 460, 4220, 460, 4240, 500, 4160, 500, 4180, 460, 4260, 480, 4180, 500, 4220, 480, 2040, 460, 2060, 460, 2180, 460];
var d = [460, 4220, 480, 2040, 460, 2100, 420, 4260, 420, 2100, 420, 4220, 500, 4220, 460, 2060, 460, 2040, 460, 4240, 460, 2040, 460, 2060, 460, 4220, 460, 2060, 460, 2040, 480, 2040, 460, 4220, 460, 2100, 460, 2040, 480, 2040, 460, 2060, 460, 2040, 460, 2060, 460, 2060, 460, 4220, 460, 4220, 460, 4220, 480, 4220, 460, 4220, 460, 4260, 420, 4260, 440, 4260, 460, 4220, 460, 2060, 460, 2040, 460, 2200, 460];
var d = [460, 4240, 460, 2040, 460, 2060, 460, 4220, 500, 2040, 460, 4240, 460, 4220, 460, 2060, 460, 2040, 460, 4240, 460, 2040, 460, 2060, 460, 2040, 480, 4220, 460, 2040, 480, 2040, 460, 4220, 500, 2060, 460, 2040, 460, 2060, 460, 2040, 480, 2040, 460, 2060, 460, 2040, 480, 4220, 460, 4220, 460, 4220, 480, 4220, 500, 4180, 500, 4180, 480, 4220, 460, 4260, 460, 2040, 460, 4240, 460, 2040, 460, 2160, 500];
var d = [420, 9380, 400, 4240, 380, 2080, 400, 2080, 400, 4220, 440, 2020, 440, 4200, 440, 4220, 440, 2020, 420, 2060, 400, 4240, 400, 2060, 420, 2040, 420, 4220, 440, 2060, 400, 4240, 420, 2020, 420, 4220, 420, 2060, 400, 2080, 400, 2060, 420, 2040, 400, 2080, 420, 2060, 420, 2020, 440, 4220, 420, 4200, 420, 4220, 440, 4220, 440, 4180, 420, 4240, 400, 4260, 380, 4260, 400, 4240, 420, 2040, 420, 4220, 440, 2160, 420, 9340, 400, 4240, 440, 2020, 420, 2060, 400, 4220, 440, 2040, 400, 4220, 440, 4220, 440, 2040, 400, 2060, 400, 4240, 420, 2040, 440, 2040, 400, 4220, 460, 2020, 420, 4220, 440, 2040, 400, 4260, 400, 2040, 440, 2020, 440, 2040, 420, 2040, 420, 2060, 420, 2040, 420, 2060, 420, 4200, 440, 4220, 400, 4220, 440, 4220, 400, 4240, 420, 4220, 420, 4220, 400, 4240, 420, 4200, 440, 2040, 420, 4220, 440, 2180, 420, 9320, 420, 4240, 400, 2040, 440, 2040, 420, 4220, 440, 2020, 420, 4220, 440, 4220, 400, 2040, 440, 2040, 420, 4200, 440, 2060, 420, 2060, 400, 4220, 420, 2060, 400, 4240, 400, 2060, 420, 4220, 440, 2060, 400, 2040, 440, 2040, 420, 2020, 440, 2060, 420, 2040, 420, 2040, 440, 4220, 420, 4220, 400, 4240, 400, 4240, 420, 4220, 420, 4220, 440, 4180, 460, 4200, 400, 4220, 440, 2060, 400, 4240, 400, 2200, 420, 9320, 420, 4220, 440, 2040, 400, 2080, 400, 4220, 440, 2040, 420, 4220, 420, 4180, 440, 2060, 420, 2040, 420, 4200, 440, 2060, 420, 2040, 420, 4240, 400, 2040, 440, 4220, 420, 2040];
*/
/*
// ba - manchester
var d = [840, 1100, 820, 1100, 820, 600, 340, 580, 360, 1100, 360, 560, 360, 600, 360, 600, 780, 1120, 360, 600, 360, 560, 820, 600, 360, 1080, 360, 580, 800, 1120, 820, 600, 320, 600, 360, 1120, 780, 1120, 360, 560, 820, 1120, 820, 1100, 340, 600, 800, 600, 360, 1100, 800, 1120, 780, 600, 360, 600, 360, 1080, 360, 600, 340, 600, 360, 560, 360, 600, 360, 600, 360, 560, 360, 580, 360, 560, 360, 600, 820, 1120, 320, 600, 820, 600, 320, 620, 340, 1120, 800, 600, 340, 1120, 340, 580, 360, 600, 800, 1120, 340, 600, 360, 560, 840, 1100, 800, 1120, 340, 580, 820, 600, 360, 580, 360, 560, 360, 1120, 360, 560, 360, 600, 820, 1080, 820, 1120, 320, 600, 820, 1080, 360, 600, 360, 600, 360, 560, 360];
var d = [860, 1080, 820, 1080, 840, 580, 360, 560, 400, 1080, 340, 580, 380, 560, 360, 600, 820, 1080, 360, 560, 400, 560, 820, 600, 360, 1080, 360, 600, 820, 1080, 820, 560, 380, 580, 340, 1100, 840, 1100, 340, 580, 840, 1100, 820, 1080, 360, 580, 840, 560, 360, 1080, 380, 560, 820, 1100, 380, 560, 360, 600, 820, 560, 360, 600, 360, 1080, 380, 560, 360, 560, 400, 560, 340, 620, 340, 580, 380, 560, 820, 1100, 380, 560, 820, 560, 400, 560, 360, 1080, 860, 560, 340, 1100, 380, 560, 360, 560, 860, 1080, 360, 560, 380, 580, 820, 1080, 840, 1100, 360, 560, 380, 560, 360, 560, 400, 560, 380, 560, 820, 580, 380, 560, 360, 1080, 380, 580, 820, 1080, 380, 580, 340, 580, 380, 560, 820, 1100, 380, 560, 380];
var d = [760, 1160, 760, 1180, 760, 640, 280, 680, 320, 1120, 320, 640, 280, 680, 280, 680, 720, 1200, 280, 640, 300, 660, 760, 640, 280, 1160, 320, 640, 760, 1180, 760, 640, 320, 640, 300, 1140, 760, 1160, 280, 680, 760, 1140, 760, 1200, 280, 640, 760, 680, 280, 1160, 280, 680, 760, 1160, 280, 680, 280, 640, 760, 660, 300, 660, 280, 1180, 280, 640, 320, 640, 320, 640, 300, 620, 340, 620, 300, 620, 760, 1200, 280, 640, 800, 620, 300, 660, 300, 1180, 740, 660, 300, 1140, 300, 660, 300, 640, 760, 1180, 300, 620, 300, 660, 760, 1160, 760, 1140, 320, 640, 300, 640, 320, 640, 320, 620, 300, 660, 760, 640, 300, 660, 300, 1140, 300, 660, 760, 1160, 300, 620, 320, 640, 320, 640, 760, 1160, 320, 640, 280];
var d = [820, 1120, 800, 1140, 800, 600, 320, 640, 320, 1140, 300, 640, 320, 600, 320, 640, 800, 1100, 360, 600, 320, 640, 760, 640, 320, 1160, 320, 600, 780, 1120, 800, 620, 320, 600, 340, 1140, 800, 1120, 320, 620, 800, 1120, 780, 1120, 360, 600, 800, 620, 320, 1120, 800, 600, 360, 1100, 340, 580, 360, 600, 800, 600, 320, 640, 320, 1120, 340, 600, 360, 600, 320, 640, 320, 600, 320, 640, 320, 600, 820, 1120, 320, 620, 780, 640, 320, 640, 320, 1120, 780, 600, 340, 1140, 320, 640, 320, 600, 800, 1120, 320, 640, 320, 620, 760, 1160, 800, 1100, 340, 620, 800, 1120, 320, 620, 340, 600, 780, 640, 320, 600, 360, 1120, 320, 600, 820, 1120, 320, 600, 820, 600, 320, 1120, 820, 1080, 360];
////var d =[880, 1000, 900, 1040, 880, 1020, 840, 1100, 840, 1060, 880, 1020, 840, 1100, 840, 1020, 880, 1060, 880, 1040, 860, 1020, 840, 1100, 880, 1000, 860, 1080, 860, 1040, 860, 540, 400, 1060, 380, 540, 880, 540, 380, 1080, 380, 540, 860, 560, 380, 1060, 380, 520, 900, 1040, 860, 1000, 880, 580, 360, 1080, 840, 1060, 420, 520, 860, 1040, 860, 560, 380, 1060, 840, 1100, 380, 540, 840, 540, 380, 1080, 860, 1040, 860, 1080, 860, 1040, 820, 1080, 400, 560, 820, 560, 380, 1100, 840, 1060, 860, 1040, 380, 580, 820, 560, 420, 1040, 820, 1100, 840, 1060, 380, 560, 820, 580, 420, 1040, 820, 1080, 860, 1040, 860, 1080, 860, 1040, 820, 1080, 860, 1040, 880, 1060, 860, 1040, 860, 1040, 880, 1060, 840, 1060, 840, 1060, 380, 540, 880, 540, 380, 1080, 860, 1040, 860, 1040, 820, 1120, 860, 1040, 860, 1040, 860, 1040, 860, 1080, 860, 1040, 380, 540, 860, 520, 420, 1040, 420, 500, 860, 560, 420, 1040, 860, 1040, 400, 560, 840, 540, 380, 1080, 860, 1060, 840, 1060, 380, 540, 880, 1040, 860, 1040, 880, 500, 420, 1060, 400, 500, 900, 520, 380, 1080, 400, 520, 860, 9220, 860, 1080, 860, 1040, 860, 1040, 880, 1020, 860, 1080, 880, 1020, 840, 1100, 840, 1060, 820, 1080, 880, 1020, 880, 1060, 840, 1060, 840, 1060, 840, 1100, 840, 1020, 860, 560, 380, 1100, 380, 520, 860, 560, 360, 1080, 420, 500, 880, 560, 400, 1000, 420, 540, 880, 1020, 840, 1080, 860, 540, 400, 1060, 820, 1080];
var d = [880, 1080, 860, 1040, 860, 560, 360, 560, 380, 1100, 340, 580, 380, 560, 400, 560, 820, 1080, 380, 540, 380, 560, 860, 560, 360, 1080, 400, 560, 820, 1080, 860, 520, 380, 580, 380, 1080, 820, 1080, 400, 520, 860, 1040, 860, 1080, 380, 540, 860, 560, 380, 1060, 380, 560, 380, 580, 820, 560, 380, 580, 380, 560, 360, 560, 400, 560, 380, 1060, 380, 560, 380, 540, 380, 580, 380, 520, 420, 580, 340, 580, 840, 1060, 380, 560, 820, 620, 340, 1080, 360, 600, 360, 560, 860, 1080, 360, 560, 380, 560, 820, 1100, 340, 600, 360, 560, 860, 1080, 820, 1080, 360, 600, 360, 560, 820, 1100, 840, 560, 360, 600, 360, 560, 380, 1100, 340, 580, 820, 1080, 860, 1080, 340, 580, 840, 580, 360, 1080, 380];
////var d = [760, 1160, 780, 1160, 760, 1120, 820, 1160, 760, 1100, 800, 1120, 780, 1120, 820, 1100, 820, 1100, 800, 1120, 820, 1120, 780, 1120, 800, 1120, 780, 1120, 820, 1120, 800, 620, 320, 1120, 340, 580, 800, 640, 320, 1120, 320, 640, 780, 640, 300, 1140, 320, 600, 820, 1100, 820, 1120, 780, 640, 320, 1120, 800, 1100, 320, 640, 800, 1120, 780, 640, 320, 1120, 760, 1180, 320, 640, 760, 600, 360, 1120, 780, 1160, 760, 1120, 780, 1160, 760, 1160, 320, 640, 760, 620, 320, 1160, 800, 1100, 760, 1200, 280, 640, 800, 600, 340, 1120, 760, 1160, 760, 1140, 360, 600, 800, 600, 360, 1100, 760, 1160, 780, 1160, 760, 1160, 780, 1120, 800, 1140, 760, 1160, 280, 640, 800, 1120, 820, 1080, 820, 600, 320, 1120, 360, 600, 780, 600, 320, 1160, 800, 1100, 760, 1200, 760, 1140, 800, 1120, 760, 1140, 760, 1180, 800, 1120, 760, 1140, 760, 1200, 780, 1120, 320, 620, 820, 600, 280, 1200, 760, 1100, 340, 620, 800, 620, 340, 1100, 320, 640, 800, 600, 320, 1160, 760, 1140, 320, 600, 820, 600, 360, 1080, 340, 580, 820, 1120, 800, 660, 300, 1120, 780, 1160, 320, 600, 800, 620, 300, 1160, 320, 8800, 760, 1120, 820, 1120, 800, 1120, 820, 1120, 780, 1080, 860, 1080, 820, 1080, 820, 1120, 800, 1120, 780, 1120, 800, 1100, 840, 1100, 820, 1120, 760, 1120, 800, 1120, 820, 600, 320, 1140, 360, 560, 820, 580, 380, 1080, 320, 600, 840, 580, 360, 1120, 320, 600, 820, 1100, 820, 1080, 820, 640];
var d = [820, 1120, 780, 1160, 760, 640, 320, 640, 280, 1160, 320, 640, 280, 640, 320, 640, 800, 1120, 340, 600, 320, 640, 760, 640, 320, 1120, 320, 640, 800, 1140, 760, 600, 360, 640, 320, 1120, 780, 1120, 320, 640, 760, 1140, 800, 1120, 320, 640, 780, 600, 320, 1160, 320, 600, 340, 620, 800, 620, 300, 640, 320, 640, 320, 640, 280, 640, 320, 1160, 320, 600, 320, 640, 280, 640, 320, 640, 300, 660, 300, 640, 780, 1160, 320, 600, 780, 600, 340, 1140, 320, 640, 320, 640, 760, 1160, 280, 640, 320, 640, 780, 1160, 300, 620, 340, 620, 760, 1160, 780, 1120, 320, 640, 320, 600, 800, 1140, 760, 680, 280, 640, 320, 640, 320, 1120, 300, 660, 760, 1160, 760, 1160, 320, 620, 760, 680, 280, 1160, 320];
*/
/*
ae013d5ac a30 09b115 e152 0    8a34c479231704e64418312
ae013d5ac 4c1 09b115 0e48 0    8a34c4792be004e64497490
                               8a34c479231704e64418312
                               8a34c4792b1704e64498395
                               8a34c47923e70464441d356



a34c4792be004e64497490
a34c479231704e64418312
a34c4792b1704e64498395
a34c47923e70464441d356
a34c47923e70464441d356
//https://github.com/robwlakes/Weather-Station-OS-Sensors/blob/master/DebugVersion_21_Final/DebugVersion_21_Final.ino

10101110000100011001011101001010011001000111000000010011101100010001010000001110010000100
10101110000100011001011101001010011001000111000000010011101100010001010000001110010000100
10101110000100011001011101001010011011000111000000010011101100010001010010001110010011010
10101110000100011001011101001010011010111000000000010011101100010001010011110001010010000
10101110000100011001011101001010011000111111000000010011000100010001010001011110010100110
10101110000100011001011101001010011000111111000000010011000100010001010001011110010100110
*/
/*
,P,1,0,0,1,0,1,1,0,0,1,0,0,1,0,1,0,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,1,0
,P,1,0,0,1,0,1,1,0,0,1,0,0,1,0,1,0,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,1,0
,P,1,0,0,1,0,1,1,0,0,1,0,0,1,0,1,0,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,1,0
,P,1,0,0,1,0,1,1,0,0,1,0,0,1,0,1,0
*/
  var c = document.getElementById("canvas");
  var ctx = c.getContext('2d');


ctx.fillStyle = "#008";
ctx.font = "bold 15px Arial";

ctx.beginPath();

var compensation = -(d[2] - d[1])/2*0
for (var i=0; i<d.length; i++)
  if (i&1) d[i] -= compensation; else d[i]+=compensation;
var t = 1000;
var l = 1;
//var k = 0.03;
var k = 0.03;
var k = 0.03; // sered-meteo
var k = 0.06; 
var bits = "";
var all = "";
for (var i=0; i<d.length+1; i++)
{
  l = 1-(i&1);
  var x = t * k;
  var y = 170 - (1-l)*140;
  if (i==0)  
    ctx.moveTo(x, y);
  else
    ctx.lineTo(x, y);
  y = 170 - l*140;
  ctx.lineTo(x, y);

  if ( i>=d.length)
    break;


  var tx = (t + d[i]/2)*k;
  ctx.fillText(d[i]+"us", tx-25, l ? 20 : 160);

  var key = "?";
/*
  if (!(i&1))
  {
    if (d[i] >= 350 && d[i] < 600)
      key = "H";
    if (d[i] >= 700 && d[i] < 1200)
      key = "HH";
  } else
  {
    if (d[i] >= 350 && d[i] < 600)
      key = "L";
    if (d[i] >= 700 && d[i] < 1200)
      key = "LL";
  }
*/

  if ((i&1))
  {
    if (d[i] >= 4000 && d[i] < 5000)
      key = "1";
    if (d[i] >= 1500 && d[i] < 2100)
      key = "0";
  } else
  {
    if (d[i] >= 400 && d[i] < 700)
      key = ",";
  }

/*

  // meteo-sered
  if (d[i] >= 360 && d[i] < 600)
    key = ",";
  if (d[i] >= 7500 && d[i] < 9500)
    key = "P";
  if (d[i] >= 3800 && d[i] < 4300) 
  {
    key = "1";
    bits += key;
  }
  if (d[i] >= 1800 && d[i] < 2300)
  {
    key = "0";
    bits += key;
  }
*/

/*
  if (d[i] >= 900 && d[i] < 1100)
    key = ",";
  if (d[i] >= 500 && d[i] < 700) 
  {
    key = "1";
    bits += key;
  }
  if (d[i] >= 1200 && d[i] < 1400)
  {
    key = "0";
    bits += key;
  }

*/

/*
  if (d[i] >= 300 && d[i] < 700)
    key = i & 1 ? "L" : "H";
  if (d[i] >= 900 && d[i] < 1100)
    key = i & 1 ? "LL" : "HH";
*/


/*  if (!(i&1))
  {
    if (d[i] >= 200 && d[i] < 350)
      key = "H";
    if (d[i] >= 700 && d[i] < 850)
      key = "HH";
  } else
  {
    if (d[i] >= 600 && d[i] < 750)
      key = "L";
    if (d[i] >= 1100 && d[i] < 1300)
      key = "LL";
  }
*/
  all += key;
  ctx.fillText(key, tx, 100);

  t += d[i];
}

ctx.stroke();
while (all[0] == "?")
  all = all.substr(2);

all = all.substr(1)
//all = "LHLHL" + all;
console.log(all);
/*
if (all.substr(-1) == ",")
  all = all.substr(0, all.length-1);
else
  all += "LHLHL";
*/

//all = all.substr(1);
all = "," + all;
bits = "";
var hasPreamble = false;
while (all.length >= 2)
{
  var segment = all.substr(0, 2);
  all = all.substr(2);
  if (segment == "HL")
    bits += "1";
  else
  if (segment == "LH")
    bits += "0";
  else
  if (segment == ",1")
    bits += "1"; 
  else
  if (segment == ",0")
    bits += "0";
  else
  if (segment == ",P")
  {
    if (hasPreamble)
      break;
    hasPreamble = true;
    bits += "";
  }
  else
    bits += "?";
}
/*
if (!hasPreamble)
{
  console.log("Bitstream with preamble: " + bits);

  var last = 1;
  var nbits = "";
  for (var i =0; i<bits.length; i++)
  {
    if (bits[i] == "0")
      last = 1-last;

    nbits += "" + last;
  }
  //bits = nbits;

while (bits[0] == "1")
  bits = bits.substr(1);

}
*/

//while (bits[0] == "1")
//  bits = bits.substr(1);

console.log(bits.length);
var t = "";
for (var i=0; i<bits.length; i+=4)
  t += bits.substr(i, 4) + " ";
console.log("Bitstream data: " + t);

var decoded = "";
var nibbles = [];
while (bits.length >= 4)
{
  var nib = bits.substr(0, 4);
  nibbles.push(rawhex(nib));
//  console.log(nib + " -> " + tohex(nib));
  decoded += tohex(nib);
  bits = bits.substr(4);
}


/*
   full oregon scientific temperature/humidity sensor frame
   af82416f1800067c55b            0.8 deg 76%
   af82416f1800067c55bc
*/

console.log("Hex: " + decoded);

if (nibbles.length == 9 && nibbles[7] == 15 && nibbles[6] == 15)
{
/*
962510ff5
 2.1 deg
*/
  var temperature = (nibbles[5]*256 + nibbles[4]*16 + nibbles[3])/10;
  console.log({wireless:{temperature:temperature}});
}
if (bits != "")
  console.log("remainder = "+bits);

if (decoded[0] == 0x0a && decoded[1] == 0x0f)
{
  var temperature = decoded[11]*10 + decoded[10]*1 + decoded[9]*0.1;
  if (decoded[12] != "0")
    temperature *= -1;
  var humidity = decoded[14]*10 + decoded[13]*1;
  console.log({oregon:{temperature:temperature, humidity:humidity}});
}

/*
console.log("bits = "+bits.length);
for (var i =0; i<bits.length; i+=8)
{
  var n = 0;
  for (var j=0; j<8; j++)
    if (bits[i+j] == "1")
       n += 1<<(j);
  console.log(n.toString(16));
}
*/
function tohex(nib)
{
  var q = 0;
  for (var i=0;  i<nib.length; i++)
    if (nib[i] == "1")
      q += 1<<i; 
  return q.toString(16);
}
function rawhex(nib)
{
  var q = 0;
  for (var i=0; i<nib.length; i++)
    if (nib[i] == "1")
      q += 1<<i; 
  return q;
}
</script>